﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DirectorRoomHelper
{
    /// <summary>
    /// Interaction logic for AddDocFileWindow.xaml
    /// </summary>
    public partial class AddDocFileWindow : Window
    {
        public AddDocFileWindow()
        {
            InitializeComponent();
            FilePath = string.Empty;
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            string text = tbxFilePath.Text.Trim().Replace("'", "");
            if (string.IsNullOrEmpty(text))
            {
                tbxFilePath.BorderBrush = FindResource("ErrorTextBoxBrush") as Brush;
                return;
            }

            FilePath = tbxFilePath.Text.Trim();
            this.Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".doc;*.docx"; // Default file extension
            dlg.Filter = "Word文件 (.doc;*.docx)|*.doc;*.docx"; // Filter files by extension
            dlg.RestoreDirectory = true;

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                tbxFilePath.Text = dlg.FileName;
            }
        }

        private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            FileDate = datePicker.SelectedDate;
            if (FileDate == null)
            {
                FileDate = DateTime.Now;
            }
        }

        public string FilePath { get; set; }
        public DateTime? FileDate { get; set; }
        public string CurrFolder
        {
            get { return txtCurrFolder.Text; }
            set { txtCurrFolder.Text = value; }
        }
    }
}
